<template>
  <div class="appHeader">
    <div class="bgBox"></div>
    <div class="leftBox">
      <img src="@/assets/home/back_icon.png" class="back" @click.native="goBack" v-if="isBack"/>
      <img src="@/assets/home/logo_icon.png" class="logo" v-else @click.native="goBack"/>
    </div>
    <div class="searchBox">
      <input type="text" v-model="searchContent"/>
      <img src="@/assets/home/search_icon.png"/>
    </div>
    <div class="rightBox">
      <img src="@/assets/home/logo_icon.png" class="logo" v-if="isBack" @click.native="goBack"/>
    </div>
  </div>
</template>

<script>
export default {
  name: 'AppHeader',
  data () {
    return {
      searchContent: '',
      isBack: false
    }
  },
  methods: {
    goBack () {
      console.log(1)
      this.$router.go(-1)
    }
  },
  watch: {
    $route (to, from) {
      console.log(to.path)
      to.path === '/HomePage' ? this.isBack = false : this.isBack = true
    }
  }
}
</script>

<style scoped lang="scss">
  .appHeader {
    width: 100%;
    height: 125px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    position: absolute;
    z-index: 99999;
    .bgBox{
      position: absolute;
      width: 100%;
      height: 125px;
      background: #6a6a6a;
      opacity: .2;
      box-shadow: 0 0 9.5px 3.5px rgba(0, 0, 0, 0.25);
    }
    .leftBox, .rightBox{
      width: 80px;
      height: 60px;
      img{
        width: 100%;
        height: 100%;
      }
      img.back{
        width: 50px;
        height: 50px;
        margin-left: 26px;
        margin-top: 7px;
      }
    }
    .searchBox{
      width: 512px;
      height: 60px;
      border-radius: 30px;
      position: relative;
      /*.van-search{*/
        /*width: 100%;*/
        /*height: 100%;*/
        /*padding: 0;*/
        /*opacity: 0.44;*/
        /*border-radius: 30px;*/
        /*/deep/ .van-cell--borderless{*/
          /*padding: 0 10px;*/
          /*border-radius: 30px;*/
        /*}*/
      /*}*/
      input{
        width: 512px;
        height: 60px;
        border: none;
        background: #fff;
        border-radius: 30px;
        position: relative;
        opacity: 0.44;
      }
      img {
        width: 24px;
        height: 24px;
        top: 15px;
        right: 20px;
        position: absolute;
      }
    }
  }
</style>
